#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
using ll = long long;

struct Plan {
  ll x, y;
  bool operator<(const Plan &other) const {

    return x - y < other.x - other.y;
    //  ||  x - y == other.x - other.y &&  x < other.x;
  }
} p[N];

int main() {
  ll n, m;
  scanf("%lld %lld", &n, &m);
  
  for (int i = 0; i < m; i++) {
    scanf("%lld %lld", &p[i].x, &p[i].y);
  }
  sort(p, p + m);

  ll ans = 0;
  for (int i = 0; i < m; i++) {
    if (n < p[i].x)
      continue;
    ll d = p[i].x - p[i].y;
    ll ci = (n - p[i].x) / d + 1ll;
    ans += ci;
    n -= ci * d;
  }

  printf("%lld\n", ans);

  return 0;
}